<?php
namespace TinyPHP;
/*
 * 框架核心文件
 * Created by tiny
 * User: tiny
 * Date: 16/06/23
 * E-mail: mountaingiant@163.com
 *
 */
class App{
    public function init(){
        //设置头 - utf-8
        $this->_setHeader();
        //载入系统配置文件
        $this->_loadSysFile();
        //自动载入函数
        $this->_setAutoload();
        //设置路由
        $this->_setRoute();
    }

    /*
     * 载入系统配置文件
     *
     * */
    private function _loadSysFile(){
        require_once dirname(__FILE__).'/Function.php';
        //1、require_once dirname(__FILE__).'/../config/Config.php';
        //2、$GLOBALS['config'] = Config.php的所有内容
        $GLOBALS['config'] = require_once dirname(__FILE__).'/../Config/Config.php';
    }

    /*
     * 头
     *
     * */
    private function _setHeader(){
        header('Content-type: text/html; charset-UTF-8');
    }

    /*
     * 自动载入函数
     *
     * */
    private function _setAutoload(){
        //自动载入函数
        require_once dirname(__FILE__).'/../TinyPHP/Autoload.php';
        $autoload = new Autoload();
        $autoload->register();
    }

    /*
     * 设置路由
     *
     * */
    private function _setRoute(){
        $routeObj = new Route();
        $routeObj->parse();
    }

}